﻿using System;
using System.Runtime.InteropServices;
using System.Text;


namespace Psglass
{
    internal static class NativeMethods
    {

        internal delegate bool EnumWindowsCallback(IntPtr hwnd, int lParam);

        [DllImport("user32.dll")]
        internal static extern int EnumWindows(EnumWindowsCallback lpEnumFunc, int lParam);
        

        [DllImport("dwmapi.dll", PreserveSig = false)]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool DwmIsCompositionEnabled();



        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        internal static extern int RegisterShellHookWindow(IntPtr hwnd);

        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        internal static extern int RegisterWindowMessage(string name);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        internal static extern int DeregisterShellHookWindow(IntPtr hwnd);

        [DllImport("dwmapi.dll")]
        internal static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);

        internal enum DWM_BB
        {
            Enable = 1,
            BlurRegion = 2,
            TransitionMaximized = 4
        }

        [StructLayout(LayoutKind.Sequential)]
        internal struct DWM_BLURBEHIND
        {
            public DWM_BB dwFlags;
            public bool fEnable;
            public IntPtr hRgnBlur;
            public bool fTransitionOnMaximized;
        }

        internal const int DWM_BB_ENABLE = 0x00000001;

        [DllImport("psapi")]
        internal static extern int EmptyWorkingSet(IntPtr handle);

        [DllImport("user32.dll", SetLastError = true)]
        internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

        internal const int HSHELL_WINDOWCREATED = 1;
        internal const int HSHELL_WINDOWDESTROYED = 2;
        internal const int HSHELL_WINDOWACTIVATED = 4;

        internal const int MAX_PATH = 255;

    }
}